package net;

import java.net.*;

public class Client {

    private final String name;
    private final InetAddress ip;

    public Client(InetAddress ip, String name) {
        this.ip = ip;
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public InetAddress getIp() {
        return ip;
    }

    @Override
    public String toString() {
        return name;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Client)) return false;

        Client client = (Client) o;

        if (name != null ? !name.equals(client.name) : client.name != null) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = (name != null ? name.hashCode() : 0);
        result = 31 * result + (ip != null ? ip.hashCode() : 0);
        return result;
    }
}
